package writer;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class BufferedWriterDemo {

	public static void main(String[] args) {
		Writer fw = null;
		BufferedWriter bw = null;
		try {
			// 创建FileWriter对象
			fw = new FileWriter("e:\\t01\\hello.txt",true);
			// 创建BufferedWriter对象
			bw = new BufferedWriter(fw);
			bw.write("今天天气好好，");
			bw.write("我想去游泳");
			bw.newLine();
			bw.write("你想去吗？");
			bw.newLine();
			bw.write("去的话我等你！");
			bw.flush();
			System.out.println("写入成功，请查看！");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				bw.close();
				fw.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}	
		}
	}
}
